home *** CD-ROM | disk | FTP | other *** search
/ Transactor / Transactor_12_1986_Transactor_Publishing.d64 / kernal who.src1 < prev    next >
Text File  |  2023-02-26  |  2KB  |  73 lines

  1. ; put "0:kernal who.src1"
  2. ;
  3. ; ********************************************************************
  4. ; program 1
  5. ; keyboard input routine using 'getin' and 'chrout' with 255 character
  6. ; buffer and automatic basic variable access. stores characters at
  7. ; $c000-$cfff. the first variable in the basic program should be a
  8. ; string (eg. a$=" "). when the program is called, this variable will
  9. ; contain the input. the length of input is controlled by the second
  10. ; variable declared by the basic program. this variable must be an
  11. ; integer (eg. a%=10) and have a value of 0-255.
  12. ; ********************************************************************
  13. ;
  14.  lda #$00    ; a zero in .a
  15.  sta $fe     ; index storage
  16.  sta $cc     ; flag to flash cursor
  17.  lda #$0a    ; variable offset
  18.  lda ($2d),y ; get low byte of second var
  19.  sta $fd     ; save it
  20. ;
  21. loop  jsr $ffe4 ; 'getin' go get a character
  22.  cmp #$00    ; is it a zero?
  23.  beq loop    ; if zero then loop
  24. ;
  25.  cmp #$0d    ; is it a return key?
  26.  beq end     ; exit if return pressed
  27. ;
  28.  cmp #$14    ; is it a delete key?
  29.  bne nodel   ; not delete then skip
  30. ;
  31.  ldy $fe     ; buffer pointer
  32.  beq loop    ; loop if buffer empty
  33. ;
  34.  dec $fe     ; delete by decrementing pointer
  35.  jmp output  ; jump output
  36. ;
  37. nodel  tax  ; save .a in the .x register
  38.  and #$7f    ; remove high bit from char
  39.  cmp #$20    ; is it a control character?
  40.  bcc loop    ; is less than #$20 yes so loop
  41. ;
  42.  txa         ; restore character to .a reg
  43.  ldy $fe     ; retrieve buffer index
  44.  cpy $fd     ; check if limit reached
  45.  bcs loop    ; carry set, limit reached
  46. ;
  47.  inc $fe     ; increment buffer pointer
  48.  bne put     ; if buffer not full skip to 'put'
  49. ;
  50.  dec $fe     ; oops, buffer full so back down one
  51.  jmp loop    ; loop
  52. ;
  53. put  sta $c000,y ; place byte in $c000 buffer
  54. ;
  55. output  jsr $ffd2 ; 'chrout' - print the character
  56.  lda #$00    ; zero
  57.  sta $d4     ; disable quote mode
  58.  jmp loop    ; play it again sam
  59. ;
  60. end  ldy #$02 ; offset to string variable length
  61.  lda $fe     ; buffer pointer
  62.  sta ($2d),y ; put in first variable length byte
  63.  iny         ; inc index y offset to pointer low byte
  64.  lda #$00    ; low order byte buffer location
  65.  sta ($2d),y ; store it in string variable pointer
  66.  iny         ; increment index
  67.  lda #$c0    ; high order byte
  68.  sta ($2d),y ; store it in string variable pointer
  69.  inc $cc     ; turn off cursor
  70.  lda #$20    ; a space to clear the cursor block
  71.  jsr $ffd2   ; print it
  72.  rts         ; and return
  73.